package com.zmzncs.lmtc.module.customer.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.zmzncs.lmtc.common.config.ClientConfig;
import com.zmzncs.lmtc.common.pojo.tengda.*;
import com.zmzncs.lmtc.module.customer.dao.CarDao;
import com.zmzncs.lmtc.module.customer.service.CardService;
import com.zmzncs.lmtc.module.order.dao.OrderInfoDao;
import com.zmzncs.lmtc.module.order.dao.OrderTradeRecordDao;
import com.zmzncs.lmtc.module.park.dao.ParkInfoDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 订单
 * </p>
 *
 * @author
 * @since 2020-09-01
 */
@Slf4j
@Service
public class CardServiceImpl implements CardService {

    public static List<TengdaForm> tengdaCardFormList = new ArrayList<>();


    /**
     * 添加车辆
     */
    @Override
    public void addCars(TengdaForm form) {
        log.info("添加车辆通知【{}】", form);
        log.info("添加车辆通知-业务数据【{}】", form.getDataItems());

        tengdaCardFormList.add(form);
        log.info("添加车辆通知-缓存通知数据【{}】", tengdaCardFormList);
    }

    /**
     * 修改车辆信息
     */
    @Override
    public void editCars(TengdaForm form) {
        log.info("修改车辆通知【{}】", form);
        log.info("修改车辆通知-业务数据【{}】", form.getDataItems());

        tengdaCardFormList.add(form);
        log.info("修改车辆通知-缓存通知数据【{}】", tengdaCardFormList);
    }

    /**
     * 车辆管理
     */
    @Override
    public void manageCars(TengdaForm form) {
        log.info("车辆管理通知【{}】", form);
        log.info("车辆管理通知-业务数据【{}】", form.getDataItems());

        tengdaCardFormList.add(form);
        log.info("车辆管理通知-缓存通知数据【{}】", tengdaCardFormList);
    }

    /**
     * 删除缓存
     */
    @Override
    @Async("threadPoolExecutor")
    public void deleteCache(TengdaForm form) {
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //  删除缓存
        tengdaCardFormList.remove(form);
    }

    /**
     * 获取固定车列表
     */
    @Override
    public void monthCardList(TengdaForm form) {
        log.info("固定车列表通知【{}】", form);
        MonthCardForm monthCardForm = JSONObject.toJavaObject(form.getDataItems().get(0), MonthCardForm.class);
        log.info("固定车列表通知-业务数据【{}】", monthCardForm);

        tengdaCardFormList.add(form);
        log.info("固定车列表通知-缓存通知数据【{}】", tengdaCardFormList);
    }

}
